//## 수신자 추가
function fnSetRcvr(userObj,target)
{
	if (userObj.value != "")
	{
		if (target == "refr") 
		{
			var comma = ",";
			var select = "bbsRef";
			if ($("#"+target).val().indexOf(userObj.value+",") > -1) return;
		}
		else 
		{
			var comma = "->";
			var select = "bbsMem";
			if ($("#"+target).val().indexOf(userObj.value+",") > -1) 
			{
				alert("이미 선택된 사람입니다. 다른사람을 선택해 주세요");
				return;
			}
		}
		var userText = $("#"+select+" option:selected").text()+comma;
		var userValue = userObj.value+",";
		$("#"+target+"s").val($("#"+target+"s").val() + userText);			
		$("#"+target).val($("#"+target).val() + userValue);			
	}
}

//## 수신자 제외
function fnRmvRcvr(mode,target)
{
	if (mode == "all")
	{
		if (target == "rcvr")
		{
			document.frmWorkBbs.rcvr.value = "";
			document.frmWorkBbs.rcvrs.value = "";
		}
		else
		{
			document.frmWorkBbs.refr.value = "";
			document.frmWorkBbs.refrs.value = "";
		}
	}
	else
	{
		if (target == "rcvr") 
		{
			var select = "bbsMem";
			var comma = "->";
		}
		else 
		{
			var select = "bbsRef";
			var comma = ",";
		}
		
		if ($("#"+select).val())
		{
			var userText = $("#"+select+" option:selected").text()+comma;
			var userValue = $("#"+select).val()+",";

			$("#"+target+"s").val($("#"+target+"s").val().replace(userText,""));			
			$("#"+target).val($("#"+target).val().replace(userValue,""));			
		}
	}
}

//## 문서 저장하기
function fnSave(){
	if(document.frmWorkBbs.subjects.value==""){
		alert("제목를 입력해 주세요.");
		document.frmWorkBbs.subjects.focus();
		return false;
	}
	if(document.frmWorkBbs.rcvrs.value==""){
		alert("결재자를 선택해 주세요.");
		document.frmWorkBbs.bbsMem.focus();
		return;
	}
	if(document.frmWorkBbs.endDt.value==""){
		alert("마감일을 선택해 주세요.");
		document.frmWorkBbs.endDt.focus();
		return;
	}
	
	var oEditor = FCKeditorAPI.GetInstance('context') ;
	var contents = oEditor.GetXHTML(true);

	if (contents == "" || contents == null || contents == '&nbsp;' || contents == '<p>&nbsp;<p>'){
		alert("내용을 입력하세요.");
		oEditor.Focus();
		return false;
	}
	try
	{
		fnSaving('on');
		document.frmWorkBbs.submit();
	}
	catch (e){
		fnSaving('off');
	}
}

function fnSaving(flag)
{
	if (flag == "on")
	{
		$("#showSaving").css("display","");
		$("#showSaving").html("저장 중 ....");
		$("#btnSave").css("display","none");
	}
	else
	{
		$("#showSaving").css("display","none");
		$("#showSaving").html("");
		$("#btnSave").css("display","");	
	}
}

function fnReset()
{
	location.href="?workSeq=<%=workSeq%>";
}